add pack_detail

FFIB 5 years ago
parent
commit
17a8f2c40b
5 changed files with 53 additions and 0 deletions
  1. 24 0
      goods/migrations/0004_auto_20200422_1216.py
  2. 3 0
      goods/models.py
  3. 20 0
      kodosale/settings.py
  4. 5 0
      kodosale/urls.py
  5. 1 0
      requirements_dj.txt

+ 24 - 0
goods/migrations/0004_auto_20200422_1216.py

@@ -0,0 +1,24 @@
1
+# Generated by Django 2.2.12 on 2020-04-22 04:16
2
+
3
+from django.db import migrations, models
4
+import simditor.fields
5
+
6
+
7
+class Migration(migrations.Migration):
8
+
9
+    dependencies = [
10
+        ('goods', '0003_auto_20200422_1110'),
11
+    ]
12
+
13
+    operations = [
14
+        migrations.AddField(
15
+            model_name='packinfo',
16
+            name='pack_detail',
17
+            field=simditor.fields.RichTextField(blank=True, help_text='包详情', null=True, verbose_name='pack_detail'),
18
+        ),
19
+        migrations.AlterField(
20
+            model_name='packinfo',
21
+            name='expired_at',
22
+            field=models.DateTimeField(blank=True, help_text='过期时间', null=True, verbose_name='expired_at'),
23
+        ),
24
+    ]

+ 3 - 0
goods/models.py

@@ -6,6 +6,7 @@ from django_models_ext import BaseModelMixin, upload_file_path, upload_file_url,
6 6
 from jsonfield import JSONField
7 7
 from shortuuidfield import ShortUUIDField
8 8
 from TimeConvert import TimeConvert as tc
9
+from simditor.fields import RichTextField
9 10
 
10 11
 from account.models import UserInfo
11 12
 
@@ -48,6 +49,7 @@ class PackInfo(BaseModelMixin):
48 49
     pack_id = ShortUUIDField(_('pack_id'), max_length=32, blank=True, null=True, help_text='包唯一标识', db_index=True, unique=True)
49 50
     title = models.CharField(_('title'), max_length=32, blank=True, null=True, help_text='标题', db_index=True)
50 51
     expired_at = models.DateTimeField(_(u'expired_at'), blank=True, null=True, help_text=_(u'过期时间'))
52
+    pack_detail = RichTextField(_(u'pack_detail'), blank=True, null=True, help_text=u'包详情')
51 53
     kol_id = models.CharField(_('kol_id'), max_length=32, blank=True, null=True, help_text='KOL 唯一标识', db_index=True)
52 54
 
53 55
     class Meta:
@@ -62,6 +64,7 @@ class PackInfo(BaseModelMixin):
62 64
         return {
63 65
             'title': self.title,
64 66
             'expired_at': tc.local_string(self.expired_at, format='%Y-%m-%d %H:%M'),
67
+            'pack_detail': self.pack_detail,
65 68
         }
66 69
 
67 70
 class PackGoodsInfo(BaseModelMixin):

+ 20 - 0
kodosale/settings.py

@@ -59,6 +59,7 @@ INSTALLED_APPS = [
59 59
     'goods',
60 60
     'kol',
61 61
     'pay',
62
+    'simditor'
62 63
 ]
63 64
 
64 65
 MIDDLEWARE = [
@@ -219,6 +220,25 @@ WECHAT = {
219 220
 
220 221
 WECHAT_DEFAULT_CFG = 'JSAPI'
221 222
 
223
+# 富文本编辑器
224
+SIMDITOR_UPLOAD_PATH = 'uploads/'
225
+SIMDITOR_TOOLBAR = [
226
+    'markdown', 'title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale',
227
+    'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link',
228
+    'image', 'hr', '|', 'indent', 'outdent', 'alignment', 'checklist', 'fullscreen', 'emoji'
229
+]
230
+SIMDITOR_CONFIGS = {
231
+    'toolbar': SIMDITOR_TOOLBAR,
232
+    'upload': {
233
+        'url': '/simditor/upload',
234
+        'fileKey': 'upload',
235
+        'image_size': 1024 * 1024 * 4  # max image size 4MB
236
+    },
237
+    'emoji': {
238
+        'imagePath': '/static/simditor/images/emoji/'
239
+    }
240
+}
241
+
222 242
 # 微信唯一标识
223 243
 # Choices: 'unionid' or 'openid'
224 244
 #

+ 5 - 0
kodosale/urls.py

@@ -44,6 +44,11 @@ urlpatterns += [
44 44
     # url(r'^page/', include(('page.urls', 'page'), namespace='page')),
45 45
 ]
46 46
 
47
+# Simditor编辑器
48
+urlpatterns += [
49
+    url(r'^simditor/', include(('simditor.urls', 'simditor'), namespace='simditor'))
50
+]
51
+
47 52
 urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
48 53
 urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
49 54
 

+ 1 - 0
requirements_dj.txt

@@ -14,3 +14,4 @@ django-shortuuidfield==0.1.3
14 14
 django-six==1.0.4
15 15
 django-uniapi==1.0.7
16 16
 django-we==1.5.5
17
+django-simditor==0.0.15